﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System.IO;

namespace Bucket.Admin.Web.Controllers
{
    /// <summary>
    /// Home Index
    /// </summary>
    public class HomeController : Controller
    {
        private readonly IWebHostEnvironment _webHostEnvironment;

        public HomeController(IWebHostEnvironment webHostEnvironment)
        {
            _webHostEnvironment = webHostEnvironment;
        }
        /// <summary>
        /// Index
        /// </summary>
        /// <param name="hostingEnvironment"></param>
        /// <returns></returns>
        public IActionResult Index([FromServices] Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)
        {
            // 获取静态文件的物理路径
            string filePath = Path.Combine(_webHostEnvironment.ContentRootPath, "wwwroot", "index.html");
            using (var stream = System.IO.File.OpenRead(filePath))
            {
                using (var reader = new StreamReader(stream))
                {
                    return Content(reader.ReadToEnd(), "text/html");
                }
            }
        }
    }
}